﻿Shader "CookbookShaders/ScrollingUV"
{
	Properties
	{
		_MainTint ("Diffuse Tint", Color) = (1, 1, 1, 1)
		_MainTex ("Texture", 2D) = "white" {}
		_ScrollXSpeed ("X Scroll Speed", Range(0, 10)) = 2
		_ScrollYSpeed ("Y Scroll Speed", Range(0, 10)) = 2
	}
	SubShader
	{
		Tags { "RenderType"="Opaque" }
		LOD 100

		CGPROGRAM
		#pragma surface surf Lambert

		fixed4 _MainTint;
		sampler2D _MainTex;
		float _ScrollXSpeed;
		float _ScrollYSpeed;

		struct Input {
			float2 uv_MainTex;
		};

		void surf(Input IN, inout SurfaceOutput o) {
			fixed2 scrollUV = IN.uv_MainTex;
			scrollUV.x += _ScrollXSpeed * _Time.y;
			scrollUV.y += _ScrollYSpeed * _Time.y;

			half4 c = tex2D(_MainTex, scrollUV);
			o.Albedo = c.rgb * _MainTint;
			o.Alpha = c.a;
		}

		ENDCG
	}
}
